<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="expires" content="no-cache">
<title>Insert title here</title>
<%
	//防止浏览器产生缓存
	response.setHeader("Pragma", "No-Cache");
	response.setHeader("Cache-Control", "No-Cache");
	response.setDateHeader("Expires", 0);

	//定义基础路径，从DispatcherServlet获取数据
	String path = request.getContextPath() + "/";
	String resourcesPath = path + "resources/";
	String omPath = resourcesPath + "operamasks-ui-2.0/";
%>
<link href="<%=omPath%>css/apusic/om-apusic.css" rel="stylesheet"	type="text/css" />
<script src="<%=omPath%>js/jquery.min.js" type="text/javascript"></script>
<script src="<%=omPath%>js/operamasks-ui.min.js" type="text/javascript"></script>
<link href="<%=path%>resources/sm/css/om-form.css" rel="stylesheet"	type="text/css" />
<script src="<%=path%>resources/sm/js/om-form.js" type="text/javascript"></script>
<script src="<%=path%>resources/sm/js/tb-function.js" type="text/javascript"></script>
<script type="text/javascript">
	var form = null;
	var path = "<%=path%>";
	var searchUrl = path + "sm/filterQuery.html";
	var extraData = {
		"view" : "VSmRmMat"
	};
	$(document).ready(
			function() {
				$('#mainGrid').omGrid(
						{
							dataSource : searchUrl,
							extraData : extraData,
							limit : 10,
							height : 320,
							colModel : [ {
								header : '物料编码',
								name : 'materialId',
								width : 100,
								align : 'center'
							}, {
								header : '物料描述',
								name : 'materialDesc',
								width : 380,
								align : 'left'
							} ],
							onRowDblClick : function(e, rowData) {
								//双击后要回填。但是由于此页面是用iframe引入到主页面的，所以要回填到父页面中去，
								//因此这里调用父页面的fillBackAndCloseDialog(rowData)方法
								window.parent.fillBackAndCloseDialog(rowData,form);
							}

						});

			});

	function initForm(newForm) {
		form = newForm;
	}
	
	//响应搜索按钮
	function search() {
		extraData = {
			"view" : "VSmRmMat"
		};
		var searchFiled = $("#search-field");// 生成搜索字段
		var group = $.bulidFilterGroup(searchFiled);		
		extraData.where = JSON.stringify(group);
		if (window.console)
			console.log(extraData.where);
		$('#mainGrid').omGrid({
			dataSource : searchUrl,
			extraData : extraData
		}, 'reload');

	};
</script>

</head>
<body>
	<form id="search-field">
		<label>物料编码:</label> <input id="materialId" name="materialId"
			class="field" type="text"></input> <label>物料描述:</label> <input
			id="materialDesc" name="materialDesc" class="field" type="text"></input>
		<button type="button" onclick="search()">搜索</button>
	</form>
	<table id="mainGrid"></table>
</body>
</html>